package com.wuming.house.service.impl;

import com.wuming.house.dao.DecorateImgMapper;
import com.wuming.house.model.DecorateImg;
import com.wuming.house.service.DecorateImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author xuhuai
 * @createTime 2019/9/16 17:33
 * @Description:
 */
@Service
public class DecorateImgServiceImpl extends BaseServiceImpl implements DecorateImgService {

    @Autowired
    private DecorateImgMapper decorateImgMapper;

    @Override
    public List<DecorateImg> getDecorateImgByDecorateId(Integer decorateId,Integer picType, int pageIndex, int pageSize) {
        Map<String,Object> params = new HashMap<>();
        params.put("decorateId",decorateId);
        params.put("picType",picType);
        try {
            return (List<DecorateImg>) this.getPageList(DecorateImgMapper.class,"selectByParams",params,pageIndex,pageSize);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public int getTotal(Integer decorateId,Integer picType) {
        Map<String,Object> params = new HashMap<>();
        params.put("decorateId",decorateId);
        params.put("picType",picType);
        try {
            return this.getTotal(DecorateImgMapper.class,"selectTotal",params);
        }catch (Exception e){
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public void deleteById(Long id) {
        try {
            decorateImgMapper.deleteByPrimaryKey(id);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Override
    public void saveDecorateImg(DecorateImg decorateImg) {
        try {
            decorateImgMapper.insert(decorateImg);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
